<?php

/**
 * Description of AliasRouter
 *
 * @author polacseka
 */
class UAL_AliasRouter extends UAL_Router
{
	public $xName = 'Rendszerszintű útvonalálnév-kezelő';

	protected $aliasList = array();

	protected $reportApplication = '';

	public function __construct(x10_Config $config=NULL)
	{
		parent::__construct($config);

		$this->reportApplication = $this->config->getConfigKey('reportApplication');

		$this->aliasList = $this->getAliasList();
	}

	protected function getAliasList()
	{
		return (array)$this->config->getConfigKey('aliasList');
	}

	public function handle()
	{
		$route = implode('/', $this->router->routeQueue);
		if (isset($this->aliasList[$route]))
		{
			$this->replaceQueue($this->parseUserQuery($this->aliasList[$route]));
		}
		else
		{
			if ($this->mode == 'strict')
			{
				$className = $this->reportApplication;
				$app = new $className();
				$app->reportStatus('A keresett tartalom ("'.$itemName.'") nem található a rendszerben - sajnáljuk.', Application::HTTP_NOT_FOUND);
				return;
			}
		}

		return TRUE;
	}
}

?>